from book.models import BookInfo,PeoplenInfo
book = BookInfo.objects.get(id=1)
book = BookInfo.objects.get(pk=5)
books = BookInfo.objects.all()
count = PeoplenInfo.object.count()

from book.models import BookInfo,PeoplenInfo
BookInfo.objects.filter(id__exact=1)
# 简写
BookInfo.objects.filter(id=1)
# get 方法1
BookInfo.objects.get(id=1)
# get 方法2
BookInfo.objects.get(pk=1)

# 查询 书名 包含'湖'的图书

# 查询 书名 以'部'结尾的图书
BookInfo.objects.filter(name__endswith='部')

# 查询 书名 为空 的图书
BookInfo.objects.filter(name__isnull=True)

# 查询 编号 为1或3或5 的图书
# in: 是否包含在范围内。
BookInfo.objects.filter(id__in=[1, 3, 5])

# 查询 编号 大于3 的图书
"""
gt大于 (greater then)
gte大于等于 (greater then equal)
lt小于 (less then)
lte小于等于 (less then equal)
"""
BookInfo.objects.filter(id__gt=3)

# 查询 1980年 发表的图书
BookInfo.objects.filter(pub_date__year=1980)

# 查询 1990年1月1日后 发表的图书
BookInfo.objects.filter(pub_date__gt='1990-1-1')
from django.db.models import F,Q
BookInfo.objects.filter(readcount__get=F('commentcount'))
BookInfo.objects.filter(readcount__get=F('commentcount')*2)
BookInfo.objects.filter(readcount__gt=20, id__lt=3)
BookInfo.objects.filter(Q(readcount__gt=20) | Q(id__lt=3))
BookInfo.objects.filter(~Q(id=3))
from django.db.models import Sum,Max
BookInfo.objects.aggregate(Sum('readcount'))
BookInfo.objects.aggregate(Max('readcount'))
BookInfo.objects.all()
BookInfo.objects.all().order_by('readcount')

from django.db.models import Sum,Max
BookInfo.objects.aggregate(Sum('readcount'))
BookInfo.objects.aggregate(Max('readcount'))
BookInfo.objects.all()
BookInfo.objects.all().order_by('readcount')

book = BookInfo.objects.get(id=1)
book.peopleninfo_set.all()
people = PeoplenInfo.objects.get(id=1)
people.book